package cn.org.qary.service.impl.qhn;

import cn.org.qary.entity.User;
import cn.org.qary.service.trait.qhn.UsersService;
import cn.org.qary.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)

public class UsersServiceImpl extends BaseServiceImpl<User> implements UsersService {
    @Override
    public User login(String username, String password) {
        User u = new User();
        u.setUsername(username);
        u.setPassword(password);
        return mapper.selectOne(u);
    }

    @Override
    public User register(User u) {
        mapper.insertSelective(u);
        return u;
    }

    @Override
    public boolean selectByName(String username) {
        User u = new User();
        u.setUsername(username);
        boolean b = true;
        User user = mapper.selectOne(u);
        if (user != null){
            b = false;
        }
        return b;
    }
}
